package com.zycfc.zsf.boot.mybatis.dynamicdatasource;

import org.slf4j.*;

public class DataSourceContextHolder
{
    private static final Logger log;
    private static final ThreadLocal<String> local;
    
    public static ThreadLocal<String> getLocal() {
        return DataSourceContextHolder.local;
    }
    
    public static void read() {
        DataSourceContextHolder.local.set(DataSourceType.read.getType());
    }
    
    public static void write() {
        DataSourceContextHolder.local.set(DataSourceType.write.getType());
    }
    
    public static void put(final String type) {
        DataSourceContextHolder.local.set(type);
    }
    
    public static String get() {
        return DataSourceContextHolder.local.get();
    }
    
    public static void clear() {
        DataSourceContextHolder.local.remove();
    }
    
    static {
        log = LoggerFactory.getLogger((Class)DataSourceContextHolder.class);
        local = new ThreadLocal<String>();
    }
}
